<template>
	    <view>
			<view style="margin-top:60rpx;font-size: 38rpx;" class="Teacher">
				<view  style="display: flex; text-align: center;">
					<!-- <view style="width: 200rpx;" @click="classIndexSkip(item)">
						<div style="margin: 30rpx 20rpx 50rpx 20rpx;position: relative;">
							<div v-if="index==3" class="num">{{count}}</div>
							<image :src="item.img" style="width: 130rpx;height: 130rpx;"></image>
							<view style="font-size: 14px;">{{item.indexName}}</view>
						</div>
					</view> -->
					
					<view style="width: 200rpx;" @click="classIndexSkip(1)">
						<div style="margin: 30rpx 20rpx 50rpx 20rpx;position: relative;">
							<image :src="indexArr[0].img" style="width: 130rpx;height: 130rpx;"></image>
							<view style="font-size: 14px;">{{indexArr[0].indexName}}</view>
						</div>
					</view>
					<view style="width: 200rpx;" @click="classIndexSkip(2)">
							<div style="margin: 30rpx 20rpx 50rpx 20rpx;position: relative;">
								<uni-badge class="uni-badge-left-margin" :text="pendingCount" absolute="rightTop" size="small">
									<image :src="indexArr[1].img" style="width: 130rpx;height: 130rpx;"></image>
								</uni-badge>
									<view style="font-size: 14px;">{{indexArr[1].indexName}}</view>	
							</div>
					</view>
					<view style="width: 200rpx;" @click="classIndexSkip(3)">
						<div style="margin: 30rpx 20rpx 50rpx 20rpx;position: relative;">
							<image :src="indexArr[2].img" style="width: 130rpx;height: 130rpx;"></image>
							<view style="font-size: 14px;">{{indexArr[2].indexName}}</view>
						</div>
					</view>
				</view>
				<view v-if="isDuty==1" class="attdenanceSty" @click="goBackIndex()">
					<view style="text-align: center;width:605rpx;font-size: 38rpx;">返回值班界面</view>
				</view>
			</view>
			<view class="logoSty"></view>
	</view>
</template>

<script>
	import violations from "@/api/modules/violation.js"
	export default {
		data() {
			return {
				queryParams: {
					pageNum: 1,
					pageSize: 5
				},
				pendingCount: 0,
				count: 0,
				isDuty: 0,
				src: this.$src,
				userName: '',
				topName: '宿舍违纪',
				showFresh: 'true',
				Attbottoms: [{
						name: 'home',
						icon: 'iconfont icon-yonghutongji',
						text: "首页",
						path: '/pages/index/supervisorIndex'
					},

					{
						name: 'maintenance',
						icon: 'iconfont icon-shezhi',
						text: "退出",
						path: '/pages/index/login'
					},
				],
				indexArr: [{
						icon: '',
						indexName: '添加违纪',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/tianjiaweiji.png',
					},
					{
						icon: '',
						indexName: '我提交的违纪',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/tijiaodeweiji.png',
					},
					{
						icon: '',
						indexName: '巡查统计',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/dor.png',
					}
				]
			}
		},

		mounted() {

		},
		onShow() {
			var that = this
			that.isDuty = uni.getStorageSync("isDuty");
			var loginId = uni.getStorageSync("loginId");
			
			this.queryParams.type = "1"
			this.queryParams.createBy = this.userName
			this.queryParams.applyStatus = '1'
			violations.getPagelist(this.queryParams).then(res => {
				this.pendingCount = res.data.total
			})

		},
		created() {
			var that = this
			// uni.getStorage({
			// 	key:"userInfo",
			// 	success:(res)=>{
			// 		that.userName = res.data
			// 		console.log(that.userName,"index")
			// 	},
			// 	fail:(res)=>{
			// 		console.log(res)
			// 	}
			// })
			that.userName = uni.getStorageSync("loginName")
			if (this.showFresh) {
				// location.reload()
				this.showFresh = false
				return;
			}

		},
		methods: {
			goBackIndex() {
				uni.navigateTo({
					url: '/pages_main/dutyCheckWorkAttendance/dutyTecIndex'
				})
			},
			classIndexSkip(item) {
				if (item == 1) {
					uni.navigateTo({
						url: "/pages_main/managementTeacher/violationSubmit/violationSubmit",
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				} else if (item == 2) {
					uni.navigateTo({
						url: "/pages_main/managementTeacher/violationSubmitedMT/violationSubmitedMT",
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				} else if (item == 3) {
					uni.navigateTo({
						url: "/pages_duty/dormitoryTeacher/patrol/patrolStatistics",
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}
			}
		}
	}
</script>

<style>
	.num {
		width: 40rpx;
		height: 40rpx;
		background-color: #F93C32;
		text-align: center;
		font-size: 12px;
		line-height: 40rpx;
		color: white;
		position: absolute;
		right: 10rpx;
		border-radius: 50%;
		z-index: 999;
	}

	.indexContent {
		/* height: 65vh; */
		/* position: relative; */
	}

	.logoSty {
		position: absolute;
		z-index: 999;
		bottom: 50rpx;
	}

	.Teacher {
		display: flex;
		/* 
		align-items: center;
		justify-content: center; */
		flex-wrap: wrap;
		margin: 60rpx;
	}







	s .content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

	}
	.uni-badge-left-margin {
			margin-left: 10px;
		}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}

	.indexContent {
		height: 100vh;
	}
</style>